package com.ss.SmartStock.mapper;

import com.ss.SmartStock.pojo.entity.Product;
import com.ss.SmartStock.pojo.entity.ProductDetails;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author author
 * @since 2024-06-17
 */
@Mapper
public interface ProductDetailsMapper extends BaseMapper<ProductDetails> {

    /***
     *  查询所有商品详细信息
     */
    @Select("select * from product_details")
    List<ProductDetails> selectAllProductDetails();

    /**
     * 根据操作人id查询对应商品详细信息
     */
    @Select("select * from product_details where operator={id}")
    List<ProductDetails> selectAllpdByUid(Long id);

    /**
     * 插入语句
     */
    @Insert("INSERT INTO product_details " +
            "(product_name, rai_type, description, rich_text, service_guarantee, exchange_restrictions, " +
            "in_stock, remaining_stock, product_picture, time_on, time_off, city_whitelist, city_blacklist, " +
            "supplier, create_time, update_time, operator, remark) " +
            "VALUES " +
            "(#{productName}, #{raiType}, #{description}, #{richText}, #{serviceGuarantee}, #{exchangeRestrictions}, " +
            "#{inStock}, #{remainingStock}, #{productPicture}, #{timeOn}, #{timeOff}, #{cityWhitelist}, #{cityBlacklist}, " +
            "#{supplier}, #{createTime}, #{updateTime}, #{operator}, #{remark})")
    @Options(useGeneratedKeys = true, keyProperty = "pDetailsId", keyColumn = "p_details_id")
    int insertProductDetails(ProductDetails productDetails);
}
